/**
 * 判断参数（字符串）是否为空
 */
exports.isBlank = (str) => {
    if (str == undefined || str == '' || str == null) {
        return true;
    }

    return false;
}

/**
 * 发起网络请求
 */
exports.requestUrl = (url, option, successFun, failedFun) => {
    // fetch(url, option).then((response) => {
    //     response.json();
    // }).catch((response) => {
    //     console.log(response);
    // });

    var request = new XMLHttpRequest();
    request.onreadystatechange = (e) => {
        if (request.readyState !== 4) {
            return;
        }

        if (request.status === 200) {
            successFun(request.responseText);
        } else {
            failedFun();
            console.warn('error');
        }
    };
    request.open('GET', url + "?" + option);
    request.send();
}